home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / SliderBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  12KB  |  318 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  07/17/97    LAB    Moved connection for setTickStyle property back into base class, since that's
  8. //                    where it is now.  Changed the TickFreq property's constrained flag to true.
  9. //                    Added connections for TickFreq property.  Added a decrement current value connection.
  10. //                    Added toggle, set, is, and is not connections for the ShowBorder property.
  11. //  09/07/97    LAB    Fixed misspelling of descriptions.
  12.  
  13. /**
  14.  * BeanInfo for Slider.
  15.  *
  16.  */
  17. public class SliderBeanInfo extends SimpleBeanInfo {
  18.  
  19.     /**
  20.      * Constructs a SliderBeanInfo object.
  21.      */
  22.     public SliderBeanInfo() {
  23.     }
  24.  
  25.     /**
  26.      * Gets a BeanInfo for the superclass of this bean.
  27.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  28.      */
  29.     public BeanInfo[] getAdditionalBeanInfo() {
  30.         try {
  31.             BeanInfo[] bi = new BeanInfo[1];
  32.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  33.             return bi;
  34.         }
  35.         catch (IntrospectionException e) { throw new Error(e.toString());}
  36.     }
  37.  
  38.     /**
  39.      * Gets the SymantecBeanDescriptor for this bean.
  40.      * @return an object of type SymantecBeanDescriptor
  41.      * @see symantec.itools.beans.SymantecBeanDescriptor
  42.      */
  43.     public BeanDescriptor getBeanDescriptor() {
  44.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  45.  
  46.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  47.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  48.                                                 "%name%.TICK_BOTH",
  49.                                                 conn.getString("TICK_BOTH")));
  50.  
  51.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  52.                                                 "%name%.TICK_NONE",
  53.                                                 conn.getString("TICK_NONE")));
  54.  
  55.  
  56.         return (BeanDescriptor) bd;
  57.     }
  58.  
  59.     /**
  60.      * Gets an array of descriptions of the methods used for "connections" by
  61.      * Visual CafΘ's Interaction Wizard.
  62.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  63.      * @return method descriptions for this bean
  64.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  65.      */
  66.     public MethodDescriptor[] getMethodDescriptors() {
  67.         Class[] args;
  68.         ConnectionDescriptor connection;
  69.         java.util.Vector connections;
  70.         java.util.Vector md = new java.util.Vector();
  71.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  72.         String s;
  73.  
  74.         try{
  75.             args = null;
  76.             MethodDescriptor getMaxValue = new MethodDescriptor(beanClass.getMethod("getMaxValue", args));
  77.  
  78.             connections = new java.util.Vector();
  79.             s=conn.getString("getMaxValue"); 
  80.             connection = new ConnectionDescriptor("output", "int", "",
  81.                                     "%name%.getMaxValue()",s);
  82.             connections.addElement(connection);
  83.  
  84.             getMaxValue.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  85.             md.addElement(getMaxValue);
  86.         } catch (Exception e) { throw new Error("getMaxValue:: " + e.toString()); }
  87.  
  88.         try{
  89.             args = new Class[1];
  90.             args[0] = java.lang.Integer.TYPE ;
  91.             MethodDescriptor setMaxValue = new MethodDescriptor(beanClass.getMethod("setMaxValue", args));
  92.  
  93.             connections = new java.util.Vector();
  94.             s=conn.getString("setMaxValue"); 
  95.             connection = new ConnectionDescriptor("input", "int", "",
  96.                                     "%name%.setMaxValue(%arg%);",s);
  97.             connections.addElement(connection);
  98.  
  99.             setMaxValue.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  100.             md.addElement(setMaxValue);
  101.         } catch (Exception e) { throw new Error("setMaxValue:: " + e.toString()); }
  102.  
  103.         try{
  104.             args = new Class[1];
  105.             args[0] = java.lang.Integer.TYPE ;
  106.             MethodDescriptor setTickStyle = new MethodDescriptor(beanClass.getMethod("setTickStyle", args));
  107.  
  108.             connections = new java.util.Vector();
  109.             s=conn.getString("setTickStyle"); 
  110.             connection = new ConnectionDescriptor("input", "int", "",
  111.                                     "%name%.setTickStyle(%arg%);",s);
  112.             connections.addElement(connection);
  113.  
  114.             setTickStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  115.             md.addElement(setTickStyle);
  116.         } catch (Exception e) { throw new Error("setTickStyle:: " + e.toString()); }
  117.  
  118.         try{
  119.             args = null;
  120.             MethodDescriptor getTickStyle = new MethodDescriptor(beanClass.getMethod("getTickStyle", args));
  121.  
  122.             connections = new java.util.Vector();
  123.             s=conn.getString("getTickStyle"); 
  124.             connection = new ConnectionDescriptor("output", "int", "",
  125.                                     "%name%.getTickStyle()",s);
  126.             connections.addElement(connection);
  127.  
  128.             getTickStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  129.             md.addElement(getTickStyle);
  130.         } catch (Exception e) { throw new Error("getTickStyle:: " + e.toString()); }
  131.  
  132.         try{
  133.             args = null;
  134.             MethodDescriptor getMinValue = new MethodDescriptor(beanClass.getMethod("getMinValue", args));
  135.  
  136.             connections = new java.util.Vector();
  137.             s=conn.getString("getMinValue"); 
  138.             connection = new ConnectionDescriptor("output", "int", "",
  139.                                     "%name%.getMinValue()",s);
  140.             connections.addElement(connection);
  141.  
  142.             getMinValue.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  143.             md.addElement(getMinValue);
  144.         } catch (Exception e) { throw new Error("getMinValue:: " + e.toString()); }
  145.  
  146.         try{
  147.             args = new Class[1];
  148.             args[0] = java.lang.Integer.TYPE ;
  149.             MethodDescriptor setMinValue = new MethodDescriptor(beanClass.getMethod("setMinValue", args));
  150.  
  151.             connections = new java.util.Vector();
  152.             s=conn.getString("setMinValue"); 
  153.             connection = new ConnectionDescriptor("input", "int", "",
  154.                                     "%name%.setMinValue(%arg%);",s);
  155.             connections.addElement(connection);
  156.  
  157.             setMinValue.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  158.             md.addElement(setMinValue);
  159.         } catch (Exception e) { throw new Error("setMinValue:: " + e.toString()); }
  160.  
  161.         try{
  162.             args = new Class[1];
  163.             args[0] = java.lang.Integer.TYPE ;
  164.             MethodDescriptor setValue = new MethodDescriptor(beanClass.getMethod("setValue", args));
  165.  
  166.             connections = new java.util.Vector();
  167.             s=conn.getString("setValueCurr"); 
  168.             connection = new ConnectionDescriptor("input", "int", "",
  169.                                     "%name%.setValue(%arg%);",s);
  170.             connections.addElement(connection);
  171.  
  172.             s=conn.getString("setValueInc"); 
  173.             connection = new ConnectionDescriptor("input", "int", "",
  174.                                     "%name%.setValue(%name%.getValue()+%arg%);",s);
  175.             connections.addElement(connection);
  176.  
  177.             s=conn.getString("setValueDec"); 
  178.             connection = new ConnectionDescriptor("input", "int", "",
  179.                                     "%name%.setValue(%name%.getValue()-%arg%);",s);
  180.             connections.addElement(connection);
  181.  
  182.             setValue.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  183.             md.addElement(setValue);
  184.         } catch (Exception e) { throw new Error("setValue:: " + e.toString()); }
  185.  
  186.         try{
  187.             args = null;
  188.             MethodDescriptor getValue = new MethodDescriptor(beanClass.getMethod("getValue", args));
  189.  
  190.             connections = new java.util.Vector();
  191.             s=conn.getString("getValue"); 
  192.             connection = new ConnectionDescriptor("output", "int", "",
  193.                                     "%name%.getValue()",s);
  194.             connections.addElement(connection);
  195.  
  196.             getValue.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  197.             md.addElement(getValue);
  198.         } catch (Exception e) { throw new Error("getValue:: " + e.toString()); }
  199.  
  200.         try{
  201.             args = new Class[1];
  202.             args[0] = java.lang.Integer.TYPE ;
  203.             MethodDescriptor setTickFreq = new MethodDescriptor(beanClass.getMethod("setTickFreq", args));
  204.  
  205.             connections = new java.util.Vector();
  206.             s=conn.getString("setTickFreq"); 
  207.             connection = new ConnectionDescriptor("input", "int", "",
  208.                                     "%name%.setTickFreq(%arg%);",s);
  209.             connections.addElement(connection);
  210.  
  211.             setTickFreq.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  212.             md.addElement(setTickFreq);
  213.         } catch (Exception e) { throw new Error("setTickFreq:: " + e.toString()); }
  214.  
  215.         try{
  216.             args = null;
  217.             MethodDescriptor getTickFreq = new MethodDescriptor(beanClass.getMethod("getTickFreq", args));
  218.  
  219.             connections = new java.util.Vector();
  220.             s=conn.getString("getTickFreq"); 
  221.             connection = new ConnectionDescriptor("output", "int", "",
  222.                                     "%name%.getTickFreq()",s);
  223.             connections.addElement(connection);
  224.  
  225.             getTickFreq.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  226.             md.addElement(getTickFreq);
  227.         } catch (Exception e) { throw new Error("getTickFreq:: " + e.toString()); }
  228.  
  229.         try{
  230.             args = new Class[1];
  231.             args[0] = java.lang.Boolean.TYPE ;
  232.             MethodDescriptor setShowBorder = new MethodDescriptor(beanClass.getMethod("setShowBorder", args));
  233.  
  234.             connections = new java.util.Vector();
  235.             s=conn.getString("setShowBorderToggle"); 
  236.             connection = new ConnectionDescriptor("input", "boolean", "",
  237.                                     "%name%.setShowBorder(!%name%.isShowBorder());",s);
  238.             connections.addElement(connection);
  239.  
  240.             s=conn.getString("setShowBorderValue"); 
  241.             connection = new ConnectionDescriptor("input", "boolean", "",
  242.                                     "%name%.setShowBorder(%arg%);",s);
  243.             connections.addElement(connection);
  244.  
  245.             setShowBorder.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  246.             md.addElement(setShowBorder);
  247.         } catch (Exception e) { throw new Error("setShowBorder:: " + e.toString()); }
  248.  
  249.         try{
  250.             args = null;
  251.             MethodDescriptor isShowBorder = new MethodDescriptor(beanClass.getMethod("isShowBorder", args));
  252.  
  253.             connections = new java.util.Vector();
  254.             s=conn.getString("isShowBorder"); 
  255.             connection = new ConnectionDescriptor("output", "boolean", "",
  256.                                     "%name%.isShowBorder()",s);
  257.             connections.addElement(connection);
  258.  
  259.             s=conn.getString("isNotShowBorder"); 
  260.             connection = new ConnectionDescriptor("output", "boolean", "",
  261.                                     "!%name%.isShowBorder()",s);
  262.             connections.addElement(connection);
  263.  
  264.             isShowBorder.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  265.             md.addElement(isShowBorder);
  266.         } catch (Exception e) { throw new Error("isShowBorder:: " + e.toString()); }
  267.  
  268.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  269.         md.copyInto(rv);
  270.  
  271.         return rv;
  272.     }
  273.  
  274.     /**
  275.      * Returns descriptions of this bean's properties.
  276.      */
  277.     public PropertyDescriptor[] getPropertyDescriptors() {
  278.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  279.  
  280.         try{
  281.         PropertyDescriptor minValue = new PropertyDescriptor("minValue", beanClass);
  282.         minValue.setBound(true);
  283.         minValue.setConstrained(true);
  284.         minValue.setDisplayName(prop.getString("minValue"));
  285.  
  286.         PropertyDescriptor maxValue = new PropertyDescriptor("maxValue", beanClass);
  287.         maxValue.setBound(true);
  288.         maxValue.setConstrained(true);
  289.         maxValue.setDisplayName(prop.getString("maxValue"));
  290.  
  291.         PropertyDescriptor tickFreq = new PropertyDescriptor("tickFreq", beanClass);
  292.         tickFreq.setBound(true);
  293.         tickFreq.setConstrained(true);
  294.         tickFreq.setDisplayName(prop.getString("tickFreq"));
  295.  
  296.         PropertyDescriptor value = new PropertyDescriptor("value", beanClass);
  297.         value.setBound(true);
  298.         value.setConstrained(true);
  299.         value.setDisplayName(prop.getString("value"));
  300.  
  301.         PropertyDescriptor showBorder = new PropertyDescriptor("showBorder", beanClass);
  302.         showBorder.setBound(true);
  303.         showBorder.setConstrained(true);
  304.         showBorder.setDisplayName(prop.getString("showBorder"));
  305.  
  306.         PropertyDescriptor[] rv = {
  307.             minValue,
  308.             maxValue,
  309.             tickFreq,
  310.             value,
  311.             showBorder};
  312.         return rv;
  313.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  314.     }
  315.  
  316.     private final static Class beanClass = Slider.class;
  317.  
  318.     }    //  end of class SliderBeanInfo